package com.example.fashionshoes.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.fashionshoes.pojo.po.Coupon;
import com.example.fashionshoes.pojo.po.UserCoupon;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserCouponMapper extends BaseMapper<UserCoupon> {
    /**
     * 获取商品可用的优惠劵
     * @return 优惠劵集合
     */
    @Select("select u.id,c.name,c.count,c.remaining,c.amount,c.discount,c.mutual,c.min_point,c.price,c.start_time,c.end_time,c.duration,c.use_type,c.relate_id,c.note,c.member_level,c.per_limit" +
            " from coupon c join user_coupon u on u.coupon_id=c.id " +
            "where u.user_id=#{userId} and c.end_time >= now() and u.status = 0")
    List<Coupon> getLimitCoupon(Integer userId, Integer goodsId);
}
